package com.tankgame;

import java.util.Vector;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: FENGYiMing
 * @Date: 2024/03/29/11:28
 * @Description: 自己的坦克
 */
public class Hero extends Tank {
    Shot shot = null;
    Vector<Shot> shots = new Vector<>();

    public Hero(int x, int y, int direct) {
        super(x, y, direct);
    }

    public void shotTank() {
        if (shots.size() == 5) {
            return;
        }
        switch (getDirection()) {
            case 0:
                shot = new Shot(getX() + 20, getY(), getDirection());
                break;
            case 1:
                shot = new Shot(getX() + 60, getY() + 20, getDirection());
                break;
            case 2:
                shot = new Shot(getX() + 20, getY() + 60, getDirection());
                break;
            case 3:
                shot = new Shot(getX(), getY() + 20, getDirection());
                break;
            default:
                break;
        }
        //自己可以发射多颗子弹
        shots.add(shot);
        new Thread(shot).start();
    }
}
